﻿#include"XQPushClientWindow.h"
#include"XQAppInfo.h"
#include"XQPushCatalogueWidget.h"
#include"XQPushClient.h"
#include"XQHttpRequestAccount.h"
#include<QMainWindow>
void XQPushClientWindow::init()
{
	XQMainWindow::init();
	init_push();
}

void XQPushClientWindow::init_catalogue()
{
	m_catalogue = new XQPushCatalogueWidget(this);
	m_mainWindows->addDockWidget(Qt::LeftDockWidgetArea, m_catalogue);
}

void XQPushClientWindow::init_push()
{
	m_push = new XQPushClient(this);
	using Debug = Http::Debug;
	m_push->setDebugModels(Debug::HeadRequest | Debug::HeadReply | Debug::error);
	m_push->setName("PushMessage");
	m_push->setLogName("PushMessage");
	m_push->connectToServer("https://www.727370630.top:6666");
	connect(m_push, &XQPushClient::connected, [this] {emit showMessage("已连接上服务器"); });
	connect(m_push, &XQPushClient::disconnected, [this] {emit showMessage("与服务器连接断开"); });
	
	auto acc = m_push->account();
	/*connect(acc, &XQHttpRequestAccount::login, [=] {
		

		});*/
	connect(acc, &XQHttpRequestAccount::errorOccurred, [this](HttpAccount::Error error) {emit showMessage(QString("发生错误:%1").arg(HttpAccount::error_toChinese(error))); });

}
